#include "Log.h"
#include "common.h"
#include "market_receiver.h"

#include <json/json.h>
#include <sys/socket.h>


#define TCP_CONNECT			 9
#define TCP_PING			 10
#define TCP_SUB				 110
#define TCP_UNSUB			 111
#define TCP_SUB_MIN			 112 //¶Ô¦serverÉµÄARKET_MIN_SUB
#define TCP_UNSUB_MIN	     		 113 //¶Ô¦serverÉµÄARKET_MIN_UNSUB
#define MARKET_DATA			 103 //¶Ô¦serverÉµÄARKET


int market_receiver::connect2mk()
{
	short market_port = 8881;
	const char* market_ip = "192.168.1.1";

	struct sockaddr_in servAddr;
	servAddr.sin_port = htons(market_port);
	servAddr.sin_family = AF_INET;
	inet_aton(market_ip,&servAddr.sin_addr);


	int market_socket = socket(PF_INET , SOCK_STREAM , 0);
	if(-1 == market_socket)
	{
		debug_output("Create Socket is faild\n");
		return 0;
	}

	if(connect(market_socket, (sockaddr*)&servAddr, sizeof(sockaddr)) == -1)
	{
		debug_output("thread_func_receive_market connect error: %d\n" , errno);
		return 0;
	}
	
	{
		Json::Value root;
		root[0] = "1";
	}	




	return 1;

}

int market_receiver::wait4market()
{
	return 1;
}
